package com.erpanderp.wam.usm.model.service.user;

import java.util.List;

import org.hibernate.Query;
import org.hibernate.Session;

import com.erpanderp.wam.usm.model.entity.user.Reference;
import com.erpanderp.wam.util.HibernateUtil;

public class ReferenceDAO {
	
	 public List<Reference> getReferences(Long newJoineeId){
			List<Reference> references = null;
			
			try{
				Session session = HibernateUtil.getSessionFactory().getCurrentSession();			
				session.beginTransaction();
				
				String queryString = "from Reference r where r.newjoinee.newJoineeId= :newJoineeId";
				
				Query query = session.createQuery(queryString).setLong("newJoineeId", newJoineeId);
				query.setCacheable(false);	
				references = (List<Reference>) query.list();					
				session.close();
				return references;
				
			}catch(Exception e){
				e.printStackTrace();
				return null;
			}			
	}

}
